//
//  UMenu.cpp
//  UltraStarDeluxeIOS
//
//  Created by 李 杰军 on 12-7-15.
//  Copyright (c) 2012年 DoReiMi. All rights reserved.
//

#include <iostream>
#include "UMenu.h"
#include "UThemes.h"

#include "UMenuBackgroundColor.h"
#include "UMenuBackgroundNone.h"

TMenu::TMenu()
{
    Background = NULL;
}

TMenu::~TMenu()
{
}

void TMenu::AddBackground(TThemeBackground ThemedSettings)
{
    switch (ThemedSettings.BGType)
    {
        case bgtColor:
            // TODO: try catch logic
            Background = new TMenuBackground(ThemedSettings);
            break;
            
        default:
            break;
    }
    
    // Fallback to None Background or Colored Background
    if (Background == NULL)
    {
        if (ThemedSettings.BGType == bgtColor)
            Background = new TMenuBackgroundNone(ThemedSettings);
        else
            Background = new TMenuBackgroundColor(ThemedSettings);
    }
}

bool TMenu::ParseInput(int PressedKey, wchar_t CharCode, bool PressedDown)
{
    return true;
}

void TMenu::OnShow()
{
    // FIXME: this needs some work. First, there should be a variable like
    // VideoBackground so we can check whether a video-background is enabled or not.
    // Second, a video should be stopped if the screen is hidden, but the Video.Stop()
    // method is not implemented by now. This is necessary for theme-switching too.
    // At the moment videos cannot be turned off without restarting USDX.
    
    // TODO: check backtround texture
    
    if (Background == NULL)
        AddBackground(DEFAULT_BACKGROUND);
    
    Background->OnShow();
}


